package com.rpp.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author peng
 * @Date 2020/7/8 1:34 下午
 */
public class CookieUtil {

    public static final String MY_COOKIE_NAME = "MY_COOKIE_NAME";

    public static boolean checkLogin(HttpServletRequest request) {
        Cookie[] cookies = request.getCookies();
        if (null == cookies || cookies.length == 0) {
            return false;
        }
        for (Cookie cookie : cookies) {
            if (!cookie.getName().equals(MY_COOKIE_NAME)) {
                continue;
            }
            if (null != cookie.getValue()) {
                return true;
            }
        }
        return false;
    }
}
